﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Windows.Design;
using Microsoft.Windows.Design.Metadata;
using Microsoft.Windows.Design.PropertyEditing;
using System.ComponentModel;

namespace AEA.WPFControls.Design
{
    internal class Metadata:IRegisterMetadata
    {

        #region IRegisterMetadata Members

        public void Register()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();            
            AddSplitButtonAttributes(builder);
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }

        private void AddSplitButtonAttributes(AttributeTableBuilder builderIn)
        {
            builderIn.AddCallback(
                typeof(SplitButton), delegate(AttributeCallbackBuilder builder)
                {
                    NewItemTypesAttribute attr = new NewItemTypesAttribute(typeof(SplitButtonItem));
                    attr.FactoryType = typeof(SplitButtonItemAdd);
                    builder.AddCustomAttributes("Items", attr);

                    CategoryAttribute itemsCategory = new CategoryAttribute("Common Properties");
                    builder.AddCustomAttributes("Items", itemsCategory);
                }
            );
        }

        #endregion
    }
}
